<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
            "http://www.w3.org/TR/html4/strict.dtd">

<jsp:directive.page errorPage="/WEB-INF/dmv/ErrorPage.jsp"/>
<jsp:directive.page import="java.util.*"/>
<jsp:directive.page import="org.twndmv.dto.*"/>
<html>
    <title>Retrieve Registration Forms</title>
    <body>
        <h2>Retrieve Registration</h2>
        
        <jsp:scriptlet>
            String handler = request.getContextPath() + "/dmv";
        </jsp:scriptlet>
        
        <p>Get Registration By ID:
        <form method="GET"
            action="<%= handler %>">
            ID: <input type="text" name="id" size="25" value=""/><p/>
            <jsp:scriptlet>
              List people = (List)request.getAttribute("sampleIds");
              String sampleIds = "";
              if(people.size() == 0) {
                sampleIds = "Empty DB, populate first";
              } else {
              for(Object o : people) {
            	  PersonDTO p = (PersonDTO)o;
            	  sampleIds += p.getId() + ", ";
              }
                sampleIds = sampleIds.substring(0, sampleIds.length() - 2);
              }
            </jsp:scriptlet>
            <p style="font:italic">Note: Some example ids include: <%= sampleIds %></p>
            <input type="submit" name="command" value="Get Registration"/>
        </form>
        
        Get Registrations By Make & Model:
        NOTE: If Make or Model drop boxes are empty, DB is empty. Add cars.
        <form method="GET"
            action="<%= handler %>">
            Make: <select name="make">
                    <jsp:scriptlet>
                      List makes = (List)request.getAttribute("make");
                      for(Object type : makes) {
                    	  String t = type.toString();
                    </jsp:scriptlet>
                    <option value="<%= t %>" ><%= t %></option>
                    <jsp:scriptlet>
                      }
                    </jsp:scriptlet>
                  </select> <p/>
            Model: <select name="model">
                    <jsp:scriptlet>
                      List models = (List)request.getAttribute("model");
                      for(Object type : models) {
                    	  String t = type.toString();
                    </jsp:scriptlet>
                    <option value="<%= t %>" ><%= t %></option>
                    <jsp:scriptlet>
                      }
                    </jsp:scriptlet>
                  </select> <p/>
            <input type="submit" name="command" value="Get Registrations By Make Model"/>
        </form>
        
        <p>Get Registration By Owner ID:
        <form method="GET"
            action="<%= handler %>">
            Owner ID: <input type="text" name="ownerId" size="25" value=""/><p/>
            <p style="font:italic">Note: Some example owners' ids include: <%= sampleIds %></p>
            <input type="submit" name="command" value="Get Registrations By Owner"/>
        </form>
        
        </body>
        </html>
        